<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*
            *  >= 0
            +  >= 1
            ?  0 || 1
            {n}  n
            {n,}  >= n
            {n,m}   n <=   <= m
            量词后面跟上? 表示非 贪婪匹配(能匹配多个，就匹配多个)
            
            x|y
        */
        var str = "haaaaaaaaaaaaaahdf";

        console.log(str.match(/a*/g)); // ["", "aaaaaaaaaaaaaa", "", "", "", ""]
        console.log(str.match(/a+/g)); // ["aaaaaaaaaaaaaa"]
        console.log(str.match(/a?/g)); // ["", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "", "", "", ""]
        console.log(str.match(/a{5}/g)); // ["aaaaa", "aaaaa"]
        console.log(str.match(/a{5,}/g)); // ["aaaaaaaaaaaaaa"]
        console.log(str.match(/a{5,8}/g)); // ["aaaaaaaa", "aaaaaa"]
        console.log('打破贪婪匹配', str.match(/a{5,8}?/g)); // ["aaaaa", "aaaaa"]

        console.log(str.match(/a|h/g));
        console.log('量词n模拟?', str.match(/a{1}|a{0}/g));
    </script>
</body>
</html>